package com.xigua.JucOfBeautiful.chapterOne.join1_4;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/1/2222:26
 */
public class JoinTest2 {
    public static void main(String[] args) {
        Thread threadOne = new Thread(()->{
            System.out.println("threadOne begin run");
            while (true){

            }
        });

        Thread mainThread = Thread.currentThread();

        Thread threadTwo = new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mainThread.interrupt();
        });

        threadOne.start();
        threadTwo.start();

        try {
            threadOne.join();
        } catch (InterruptedException e) {
            System.out.println("main thread:"+e);
        }

    }
}
